// setInterval 实现倒计时
const totalDuration = 10; // 倒计时 10s
let duration = totalDuration;
let countDownInterval = null;

function countDown() {
  countDownInterval = setInterval(() => {
    duration = duration - 1;
    console.log(duration)
    if (duration <= 0) {
      clearInterval(countDownInterval)
    }
  }, 1000);
}

countDown()

// 缺点 